
package com.bash.carrep.dao.enties;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author bash
 */
@Entity
@Table(name = "pp", catalog = "carrepdb", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Pp.findAll", query = "SELECT p FROM Pp p"),
    @NamedQuery(name = "Pp.findByNif", query = "SELECT p FROM Pp p WHERE p.nif = :nif"),
    @NamedQuery(name = "Pp.findByNom", query = "SELECT p FROM Pp p WHERE p.nom = :nom"),
    @NamedQuery(name = "Pp.findByPostnom", query = "SELECT p FROM Pp p WHERE p.postnom = :postnom"),
    @NamedQuery(name = "Pp.findByPrenom", query = "SELECT p FROM Pp p WHERE p.prenom = :prenom"),
    @NamedQuery(name = "Pp.findByDateNaiss", query = "SELECT p FROM Pp p WHERE p.dateNaiss = :dateNaiss")})
public class Pp implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 9)
    @Column(name = "NIF", nullable = false, length = 9)
    private String nif;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "nom", nullable = false, length = 45)
    private String nom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "postnom", nullable = false, length = 45)
    private String postnom;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "prenom", nullable = false, length = 45)
    private String prenom;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dateNaiss", nullable = false)
    @Temporal(TemporalType.DATE)
    private Date dateNaiss;
    @JoinColumn(name = "NIF", referencedColumnName = "NIF", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Personne personne;

    public Pp() {
    }

    public Pp(String nif) {
        this.nif = nif;
    }

    public Pp(String nif, String nom, String postnom, String prenom, Date dateNaiss) {
        this.nif = nif;
        this.nom = nom;
        this.postnom = postnom;
        this.prenom = prenom;
        this.dateNaiss = dateNaiss;
    }

    public String getNif() {
        return nif;
    }

    public void setNif(String nif) {
        this.nif = nif;
    }

    public String getNom() {
        return nom;
    }

    public void setNom(String nom) {
        this.nom = nom;
    }

    public String getPostnom() {
        return postnom;
    }

    public void setPostnom(String postnom) {
        this.postnom = postnom;
    }

    public String getPrenom() {
        return prenom;
    }

    public void setPrenom(String prenom) {
        this.prenom = prenom;
    }

    public Date getDateNaiss() {
        return dateNaiss;
    }

    public void setDateNaiss(Date dateNaiss) {
        this.dateNaiss = dateNaiss;
    }

    public Personne getPersonne() {
        return personne;
    }

    public void setPersonne(Personne personne) {
        this.personne = personne;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (nif != null ? nif.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Pp)) {
            return false;
        }
        Pp other = (Pp) object;
        if ((this.nif == null && other.nif != null) || (this.nif != null && !this.nif.equals(other.nif))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.bash.carrep.dao.enties.Pp[ nif=" + nif + " ]";
    }
    
}
